<template>

	<view class="u-p-l-14 u-p-r-14 bg-white">
		<u-form label-width="auto" :model="form" ref="formEl" :border-bottom="false" label-position="top">
			<u-form-item label="设置起步价" prop="startPrice">

				<u-input type="digit" v-model="form.startPrice" placeholder="请输入起步价"></u-input>

			</u-form-item>
		</u-form>



	</view>

	<view class="btnwrap u-p-t-80 u-p-l-80 u-p-r-80">
		<u-button type="warning" @click="submit">确定</u-button>
	</view>

</template>

<script setup >
	import shopApi from '@/api/shop'
	import { onLoad, onReady } from '@dcloudio/uni-app'
	import { reactive, ref } from "vue";


	onLoad(() => {
		shopApi.getShopDetal().then(res => {
			form.startPrice = res.data.startPrice || ''
		})
	})

	onReady(() => {
		formEl.value.setRules(rules)
	})

	const formEl = ref(null)
	const form = reactive({
		startPrice: '',
		type: 2
	})

	const rules = reactive({
		startPrice: [
			{
				required: true,
				message: '请输入新起步价',
				trigger: ['change', 'blur'],
			},
			{
				max: 6,
				message: "起步价过大",
				trigger: ['change', 'blur'],
			}
		]
	})


	function submit() {
		formEl.value.validate(valid => {
			if (valid) {
				shopApi.setPortinfo(form).then(res => {
					uni.showToast({
						title: res.msg
					})
				})
			}
		})
	}
</script>

<style>
</style>
